package com.well.kernel.spring.web.easyui;

import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.io.Serializable;
import java.util.List;

/**
 * Copyright &copy; Well All rights reserved.
 * Author:Well
 * Date:2016-12-12
 * Description:AJAX请求时，返回 datagrid 数据格式
 */

public class Datagrid<T> implements Serializable {

	/* 数据列表记录 */
	private List<T> rows;
	
	/* 查询的列表总数 */
	private Long total;

	public Datagrid(){}
	
	public Datagrid(List<T> rows,Long total)
	{
		this.rows=rows;
		this.total=total;
	}

	public Datagrid(PageInfo<T> pageInfo)
	{
		this.rows=pageInfo.getList();
		this.total=pageInfo.getTotal();
	}

	public List<T> getRows() {
		return rows;
	}

	public void setRows(List<T> rows) {
		this.rows = rows;
	}

	public Long getTotal() {
		return total;
	}

	public void setTotal(Long total) {
		this.total = total;
	}

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    }

}
